<?php


class Admin_Form_CourseMedia_Import extends Zend_Form {

   public function __construct($options = null) {
      parent::__construct($options);
      
      $view = Zend_Layout::getMvcInstance()->getView(); 
//      $courseMediaModel = new Model_Coursemedia();
//      $group = $groupModel->findOneBy('id', $groupid);
      $this->setName('courseMedia_Import_Form');
      
      $courseModel =  new Model_Courses();
      $courses = $courseModel->getList(
         'title', 
         'courseid', 
         array('' => 'Select a Course'), 
         null, 
         array('lang' => sprintf("'%s'", Zend_Registry::get('Zend_Locale')->getLanguage()))
      );
      $clist = new Zend_Form_Element_Select('course');
      $clist->setRequired(true)
                 ->setLabel($view->translate->_('Course'))
                 ->setMultiOptions($courses)
                 ->isRequired()
      ;
      
      $types = new Zend_Form_Element_Select('type');
      $types->setLabel($view->translate->_('Type'))
                ->setMultiOptions(array('audio' => 'AUDIO', 'video' => 'VIDEO'));
      
      $exts = new Zend_Form_Element_Select('ext');
      $exts->setLabel($view->translate->_('Extension'))
                ->setMultiOptions(array('mp3' => 'MP3', 'flv' => 'FLV'));
                
      $mime = new Zend_Form_Element_Select('mime');
      $mime->setLabel($view->translate->_('Mime Type'))
                ->setMultiOptions(array('audio/mp3' => 'audio/mp3', 'video/x-flv' => 'video/x-flv'));
                
      $fields = array(
         //'language' => $langlist,
         'course' => $clist,
         'folder' => new Zend_Form_Element_Text('folder', array(
            'label' => $view->translate->_('Folder') . ' (relative to /media/hti/)', 
            'required' => true, 
            'value' => ''
         )),
         'type' => $types,
         'ext' => $exts,
         'mime' => $mime,
         'submit' => new Zend_Form_Element_Submit('login', array(
            'label' => $view->translate->_('Submit')
         ))
      );
      $fields['folder']->addFilter(new Zend_Filter_StringTrim())
                       ->addValidator(new Admin_Validate_FolderExists($this))
                       ->isRequired();
      
      $this->addElements($fields);
      $this->setMethod('post');
      $this->setAction(
         sprintf('%s/%s/%s/%s', 
            Zend_Controller_Front::getInstance()->getBaseUrl(),
            'admin',
            $options['params']['controller'],
            $options['params']['action']
         ));

   }


}